// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function addToFavoriate(title, url)
{
  if (window.sidebar)
  {
    window.sidebar.addPanel(title, url, '');
  }
  else if (window.external)
  {
    window.external.AddFavorite(url, title);
  }
  else
  {
    alert('sorry, can not add to bookmark.');
  }
}

function copy(inElement)
{
  alert('已经成功复制以下内容到剪贴板，你可以通过Ctrl+V粘贴到QQ/MSN/论坛签名档：\n\n'+inElement.innerHTML);
  if (inElement.createTextRange)
  {
    var range = inElement.createTextRange();
    if(range)
    {
      range.execCommand('Copy');
    }
  }
  else
  {
    var flashcopier = 'flashcopier';
    if(!document.getElementById(flashcopier))
    {
      var divholder = document.createElement('div');
      divholder.id = flashcopier;
      document.body.appendChild(divholder);
    }
    document.getElementById(flashcopier).innerHTML = '';
  	var divinfo = '<embed src="/flashs/clipboard.swf" flashvars="clipboard='+inElement.value+'" width="0" height="0" type="application/x-shockwave-flash"/>';
  	document.getElementById(flashcopier).innerHTML = divinfo;
  }
}

function fullscreen()
{
  obj = $('videoObject');
  if (navigator.appName.indexOf("Microsoft") != -1)
  {       
    obj.width = document.documentElement.clientWidth + 'px'; 
    obj.height = (document.documentElement.clientHeight - 24) + 'px'; 
  }       
  else    
  {       
    obj.width = (document.documentElement.clientWidth - 20) + 'px'; 
    obj.height = (document.documentElement.clientHeight - 24) + 'px'; 
  }
}

function show_all(name)
{
  var objs = $(name).getElementsByTagName('tr');
  for(i = 1;i<objs.length;i++)
  {
    objs[i].style.display = '';
    objs[i].style.backgroundColor = '';
  }
}

function show_update(name)
{
  var objs = $(name).getElementsByTagName('tr');
  var j = 0;
  for(i = 1;i<objs.length;i++)
  {
    if (objs[i].className.match(/updates/))
    {
      objs[i].style.display = 'none';
    }
    else
    {
      j++;
      if (j % 2 == 1)
        objs[i].style.backgroundColor = '#e6e6e6';
      else
        objs[i].style.backgroundColor = '#ffffff';
    }
  }
}
			
var Cookie = {
  set: function(name, value, daysToExpire) {
    var expire = '';
    if (daysToExpire != undefined) {
      var d = new Date();
      d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
      expire = '; expires=' + d.toGMTString();
    }
    return (document.cookie = escape(name) + '=' + escape(value || '') + expire);
  },
  get: function(name) {
    var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]*)'));
    return (cookie ? unescape(cookie[2]) : null);
  },
  erase: function(name) {
    var cookie = Cookie.get(name) || true;
    Cookie.set(name, '', -1);
    return cookie;
  },
  accept: function() {
    if (typeof navigator.cookieEnabled == 'boolean') {
      return navigator.cookieEnabled;
    }
    Cookie.set('_test', '1');
    return (Cookie.erase('_test') === '1');
  }
};

function set_feedback()
{
  Cookie.set('nickname', $('feedback_nickname').value, 365)
  Cookie.set('email', $('feedback_email').value, 365)
}

function set_report()
{
  Cookie.set('nickname', $('report_nickname').value, 365);
  Cookie.set('email', $('report_email').value, 365);
}

function load_flash(url, width, height)
{
  document.write('<embed src="' + url + '" wmode="transparent" allowscriptaccess="always" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" />');
}